package com.belinda.springboot_mybatis.controller;

import com.belinda.springboot_mybatis.model.Person;
import com.belinda.springboot_mybatis.service.impl.MongoDBServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mongodb")
public class MongoDBController {
    @Autowired
    private MongoDBServiceImpl mongoDBService;

    @RequestMapping("/save")
    public Person savePerson(){
        Person person = new Person("Alice", 20);
        return mongoDBService.savePerson(person);
    }

    @RequestMapping("/findByName")
    public Person findByName(String name){
        return mongoDBService.findByName(name);
    }

    @RequestMapping("/findAll")
    public List<Person> findAll(){
        return mongoDBService.findAll();
    }


}
